package io.kiki.sba.registry.common.model.slot;

import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;

@Setter
@Getter
public final class SlotAccess implements Serializable {

    private final int slotId;
    private final Status status;
    private final long slotsEpoch;
    private final long slotLeaderEpoch;

    public SlotAccess(int slotId, long slotsEpoch, Status status, long slotLeaderEpoch) {
        this.slotsEpoch = slotsEpoch;
        this.slotId = slotId;
        this.status = status;
        this.slotLeaderEpoch = slotLeaderEpoch;
    }

    public boolean isMoved() {
        return status == Status.moved;
    }

    public boolean isMigrating() {
        return status == Status.migrating;
    }

    public boolean isAccept() {
        return status == Status.accept;
    }

    public boolean isMisMatch() {
        return status == Status.mismatch;
    }


    public enum Status {
        accept, migrating, moved, mismatch, unsupport,
    }
}
